package me.itxuye.moment;

import android.app.Application;
import com.squareup.okhttp.OkHttpClient;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import me.itxuye.moment.net.OkHttpClientManager;
import me.itxuye.moment.utils.TestUrls;
import okio.Buffer;

/**
 * Author  : itxuye(itxuye@gmail.com)|(http://itxuye.com)
 * Date    : 2015-12-02
 * Time    : 19:11
 * FIXME
 */
public class APP extends Application implements TestUrls {

  @Override public void onCreate() {
    super.onCreate();
    initHttpClient();
  }

  /*
     初始化Okhttp
   */
  private void initHttpClient() {
    OkHttpClientManager.getInstance().setCertificates(new InputStream[] {
        new Buffer().writeUtf8(CER_12306).inputStream()
    });
    OkHttpClient httpClient = OkHttpClientManager.getInstance().getOkHttpClient();
    httpClient.setConnectTimeout(10 * 1000, TimeUnit.MILLISECONDS);
    httpClient.setWriteTimeout(30 * 1000, TimeUnit.MILLISECONDS);
    httpClient.setWriteTimeout(30 * 1000, TimeUnit.MILLISECONDS);
  }
}
